package com.ramnight.unify.boot;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;

import com.ramnight.unify.boot.EnableUnifyBoot.UnifyBootConfiguration;
import com.ramnight.unify.boot.spring.SpringPropKit.YmlPropertySourceFactory;

@Target(value = { ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Import(UnifyBootConfiguration.class)
public @interface EnableUnifyBoot {

	// componentScan 直接放到enable注解上不起作用，需要放到configuration上
	@Configuration
	@ComponentScan("com.ramnight.unify.boot")
	@PropertySource(value = {"classpath:unify-boot-frame.yml", "classpath:unify-boot-app.yml"}, factory = YmlPropertySourceFactory.class)
	public static class UnifyBootConfiguration {
		// @Bean
		// public PropertySourcesPlaceholderConfigurer unifyBootPlaceholderConfigurer()
		// {
		// return SpringPropKit.placeholderConfigurer("unify-boot.yml");
		// }
	}
}
